<template>
  <div>
    <h1>循环渲染指令</h1>
    <ul>
      <li v-for="(item, index) in list" :key="item.id">
        <input type="checkbox" />
        {{ index + 1 }} -- {{ item.id }} -- {{ item.name }} --
        {{ item.nickname }}
        <button @click="del(item.id)">删除</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [
        { id: 100, name: "宋江", nickname: "及时雨" },
        { id: 200, name: "吴用", nickname: "智多星" },
        { id: 300, name: "林冲", nickname: "豹子头" },
        { id: 400, name: "林冲", nickname: "豹子头" },
        { id: 500, name: "林冲", nickname: "豹子头" },
        { id: 600, name: "林冲", nickname: "豹子头" },
        { id: 700, name: "林冲", nickname: "豹子头" },
      ],
    };
  },
  methods: {
    del(id) {
      this.list = this.list.filter((item) => {
        return item.id != id;
      });
    },
  },
};
</script>

<style>
h1 {
  color: #fe7299;
}
</style>

